/**
 * 获取店铺信息并缓存
 */
function getShopMsg() {
  let shopMsgStr = handleLocalStorage("get", "_shopMsg");
  if (!shopMsgStr) {
    sm.req({
      url: "/sysShop/myShopMsg",
      async: false,
      noAlert: true,
      done: function (res) {
        if (res.code == 200) {
          if (JSON.stringify(res.data) === "{}" || res.data == null || res.data == undefined || res.data == "") {
            return false;
          } else {
            shopMsgStr = JSON.stringify(res.data);
            handleLocalStorage("set", "_shopMsg", shopMsgStr);
          }
        } else {
          return false;
        }
      },
    });
  }
  return JSON.parse(shopMsgStr);
}
/**
 * 删除店铺缓存信息
 */
function removeShopMsg() {
  handleLocalStorage("remove", "_shopMsg");
}
/**
 * 加载图片时发生错误执行函数
 * @param {object} img
 */
function imgerr(img) {
  img.src = "/temp/noimg.png";
  img.onerror = null;
}
/**
 * 底部导航栏个人中心根据身份切换
 */
function showCenter() {
  let shopMsg = getShopMsg();
  if (false == shopMsg) {
    $("#myCenter").attr("href", "myCenter.html");
  } else {
    if (shopMsg.shopType == 1) {
      //景区
      $("#myCenter").attr("href", "viewCenter.html");
    } else {
      $("#myCenter").attr("href", "unionCenter.html");
    }
  }
}
/**
 * 首页注册链接根据身份切换
 */
function indexShowCenter() {
  let shopMsg = getShopMsg();
  if (false == shopMsg) {
    $("#view_register").attr("href", "view.html");
    $("#union_register").attr("href", "union.html");
  } else {
    if (shopMsg.shopType == 1) {
      //景区
      $("#union_register").attr("href", "union.html");
    } else {
      $("#view_register").attr("href", "view.html");
    }
  }
}
/**
 * 获得车主卡信息
 */
function getCardMsg() {
  let cardMsgStr = handleLocalStorage("get", "_cardMsg");
  if (!cardMsgStr) {
    sm.req({
      url: "/sysUserCard/myCard",
      async: false,
      noAlert: true,
      done: function (res) {
        if (res.code == 200) {
          if (JSON.stringify(res.data) === "{}" || res.data == null || res.data == undefined || res.data == "" || JSON.stringify(res.data.userCar) === "{}" || JSON.stringify(res.data.userCard) === "{}") {
            return false;
          } else {
            cardMsgStr = JSON.stringify(res.data);
            handleLocalStorage("set", "_cardMsg", cardMsgStr);
          }
        } else {
          return false;
        }
      },
    });
  }
  return JSON.parse(cardMsgStr);
}
/**
 * 删除车主卡缓存信息
 */
function removeCardMsg() {
  handleLocalStorage("remove", "_cardMsg");
}
